<template>
  <div>
    <the-header-top></the-header-top>
    <logo-bar></logo-bar>
    <div class="logistics-body">
      <div>
        <!--面包屑-->
        <ul class="breadcrumb">
          <li><router-link to="/personal">{{ $t('message.PersonalOrderLogisticsMyAccount') }}</router-link></li>
          <li><router-link to="/personal/order/0/1">{{ $t('message.PersonalOrderLogisticsMyOrder') }}</router-link></li>
           <li>{{ $t('message.afterSaleProgress') }}</li>
        </ul>
      </div>
      <div class="wrapContent">
        <v-title>{{ $t('message.afterSaleServe') }}</v-title>
        <div class="sale-status">
          <div class="commodity-img">
            <img :src="orderDetails.icon1" :alt="orderDetails.goods_name">
          </div>
          <div class="commodity-param">
            <p>{{ orderDetails.goods_name }} {{ orderDetails.sxzh_name }} {{ orderDetails.yjsx_name }}</p>
            <p>{{ $t('message.color') }}：{{ orderDetails.sxzh_name }}</p>
            <p>{{ $t('message.version') }}：{{ orderDetails.yjsx_name }}</p>
          </div>
        </div>
        <div class="choose-sort">
          <!--<p>请选择服务类型</p>-->
          <p>{{ $t('message.chooseServeSort') }}</p>
          <div class="apply-serve" :class="{active: nowIndex === 'barter'}" @click="chooseSort('barter')">
            <div>
              <img src="../../../assets/images/personal/icon_barter.png" alt="">
            </div>
            <div class="sort-text">
              <p>{{ $t('message.applyBarter') }}</p>
              <p>{{ $t('message.needBarter') }}</p>
            </div>
          </div>
          <div class="apply-serve" :class="{active: nowIndex === 'return'}" @click="chooseSort('return')">
            <div>
              <img src="../../../assets/images/personal/icon_return.png" alt="">
            </div>
            <div class="sort-text">
              <p>{{ $t('message.applySalesReturn') }}</p>
              <p>{{ $t('message.needReturn') }}</p>
            </div>
          </div>
        </div>
        <div class="next">
          <button type="button" @click="next">{{ $t('message.next') }}</button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import TheHeaderTop from '@/components/base/TheHeaderTop'
  import LogoBar from '@/components/base/LogoBar'
  import VTitle from '@/components/base/VTitle'

  export default {
    name: 'PersonalOrderAfterSale',
    components: {
      TheHeaderTop,
      LogoBar,
      VTitle
    },
    data () {
      return {
        nowIndex: 'barter',
        orderDetails: {},
        orderType: ''
      }
    },
    computed: {
      orderId () {
        return this.$route.query.orderId
      }
    },
    methods: {
      chooseSort (val) {
        if (val === 'barter') {
          this.nowIndex = 'barter'
        } else {
          this.nowIndex = 'return'
        }
      },
      next () {
//        换货
        if (this.nowIndex === 'barter') {
          this.$router.push({path: '/personal/order/barter', query: {orderId: this.orderId, orderType: this.orderType}})
        } else {
//        退货
          this.$router.push({path: '/personal/order/return', query: {orderId: this.orderId, orderType: this.orderType}})
        }
      },
      getOrderDetails () {
        this.$ajax.orderDetails({
          id: this.orderId
        }).then((res) => {
          if (res.code === 200) {
            this.orderDetails = res.data
            if (res.data.order_status === 19) {
              this.orderType = 'barterComplete'
            } else {
              this.orderType = 'dealComplete'
            }
          } else if (res.code === 202) {
            this.$store.commit('alert', {
              switch: true,
              alertText: this.$t('message.requestDataFailed')
            })
            console.log('请求数据失败数据为空')
          } else if (res.code === 301) {
            this.$router.push({path: '/login', query: {redirect: this.$route.fullPath}})
          }
        })
      }
    },
    created () {
      this.getOrderDetails()
    }
  }
</script>

<style scoped>
  .logistics-body {
    background: #F5F5F5;
    min-width: 1200px;
    padding-bottom: 40px;
  }
  .breadcrumb {
    margin: 0 auto;
    width: 1200px;
    padding-top: 20px;
    overflow: hidden;
  }

  .breadcrumb li {
    float: left;
    height: 20px;
    line-height: 20px;
    font-size: 14px;
    color: #666;
  }

  .breadcrumb a {
    color: #666;
  }

  .breadcrumb a:after {
    content: "\003e";
    display: inline-block;
    height: 20px;
    padding: 0 4px;
  }
  .wrapContent {
    padding: 40px;
    margin: 20px auto 0;
    width: 1200px;
    background: #FFFFFF;
  }
  .sale-status {
    width: 600px;
    border-bottom: 1px solid #E6E6E6;
    font-size: 0;
    padding: 40px 0;
  }
  .sale-status > div {
    display: inline-block;
  }
  .commodity-img {
    width: 90px;
    height: 90px;
  }
  .commodity-img > img {
    width: 100%;
  }
  .commodity-param {
    vertical-align: middle;
    font-size: 12px;
    color: #666666;
    margin-left: 29px;
  }
  .commodity-param p:nth-of-type(1) {
    font-size: 14px;
    color: #333333;
    line-height: 26px;
    width: 400px;
    text-overflow: ellipsis;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  .choose-sort {
    padding-top: 40px;
    font-size: 0;
    margin-bottom: 60px;
  }
  .choose-sort > p {
    font-size: 16px;
    color: #333333;
    margin-bottom: 24px;
  }
  .choose-sort > div {
    font-size: 16px;
    display: inline-block;
    width: 450px;
    height: 110px;
    background: #FFFFFF;
    border: 1px solid #E6E6E6;
    border-radius: 2px;
    vertical-align: middle;
  }
  .choose-sort > div:last-child {
    margin-left: 24px;
  }
  .apply-serve {
    font-size: 0;
  }
  .apply-serve:hover {
    border: 1px solid #FF600A;
    cursor: pointer;
  }
  .apply-serve > div {
    display: inline-block;
  }
  .apply-serve > div:first-child {
    width: 40px;
    height: 40px;
    vertical-align: top;
    margin: 35px 24px 0 30px;
  }
  .apply-serve > div > img {
    width: 100%;
    height: 100%;
  }
  .apply-serve > div:last-child {
    margin-top: 30px;
  }
  .sort-text > p:first-child{
    font-size: 16px;
    color: #333333;
  }
  .sort-text > p:last-child{
    font-size: 14px;
    color: #A5A5A5;
  }
  .next > button{
    width: 140px;
    height: 48px;
    background: #FF600A;
    border: none;
    font-size: 16px;
    color: #FFFFFF;
    cursor: pointer;
  }
  .choose-sort .active {
    border: 1px solid red;
    background: url(../../../assets/images/icon_check.png) no-repeat top right;
  }

</style>
